{***************************************************************
    SpyGestion  Copyright (C) 2008 Christophe KOALI <nature2gas@gmail.com>
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
****************************************************************}
unit modPopupAdv;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, StdCtrls, ImgList,
  Menus, BarMenus, BcRectUtilities, BcDrawModule, BcCustomDrawModule;

  
procedure outilsDrawGradient(Canvas: TCanvas; ARect: TRect; StartingColor,
  EndingColor: TColor; Style: TGradientStyle);


implementation


var FDrawBuffer: TBitMap;

{ Gradient drawing uses DrawBuffer to buffer the drawing to memory and then
  copying drawn part to visible screen (makes things faster but uses a bit
  more memory and resources). Recommended way if using gsDiagonal* gradient
  styles. BarMenus.DrawGradient does not use buffer as it is low level procedure. }
procedure outilsDrawGradient(Canvas: TCanvas; ARect: TRect; StartingColor,
  EndingColor: TColor; Style: TGradientStyle);

begin
  FDrawBuffer.Height := RectHeight(ARect);
  FDrawBuffer.Width := RectWidth(ARect);
  BarMenus.DrawGradient(FDrawBuffer, nil, BitmapRect(FDrawBuffer), startingColor, EndingColor, Style);
  Canvas.Draw(ARect.Left, ARect.Top, FDrawBuffer); // copy the buffer
  FDrawBuffer.Height := 0;
  FDrawBuffer.Width := 0;
end;

initialization
    FDrawBuffer := TBitMap.Create;

finalization
    FDrawBuffer.Free;

end.
